package com.heyqing.ems.controller;

import com.heyqing.ems.po.ModifyPo;
import com.heyqing.ems.po.OpEmployeePo;
import com.heyqing.ems.po.OpManagerPo;
import com.heyqing.ems.po.QueryPo;
import com.heyqing.ems.service.ManagerService;
import com.heyqing.ems.vo.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * ClassName:ManagerController
 * Package:com.heyqing.ems.controller
 * Description:
 *
 * @Date:2024/6/26
 * @Author:Heyqing
 */
@Api(value = "经理")
@RestController
@RequestMapping("manager")
@RequiredArgsConstructor
public class ManagerController {

    private final ManagerService managerService;

    /**
     * 列表查询
     *
     * @param queryPo
     * @return
     */
    @ApiOperation("查询列表")
    @PostMapping("list")
    public Result list(@RequestBody QueryPo queryPo) {
        return managerService.getList(queryPo);
    }

    /**
     * 添加/修改员工
     *
     * @param opEmployeePo
     * @return
     */
    @ApiOperation("添加/修改员工")
    @PutMapping("save")
    public Result saveManger(@RequestBody OpEmployeePo opEmployeePo) {
        return managerService.saveEmployee(opEmployeePo);
    }


    @ApiOperation("添加/修改员工密码")
    @PutMapping("modify")
    public Result modify(@RequestBody ModifyPo modifyPo) {
        return managerService.modify(modifyPo);
    }

    @ApiOperation("删除员工")
    @DeleteMapping("delete/{id}")
    public Result deleteManger(@PathVariable Long id) {
        return managerService.delete(id);
    }
}
